/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jps.main;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import jps.datastore.ComplexObject;
import jps.datastore.SBAStore;
import jps.model.*;
import org.jdom.JDOMException;

/**
 *
 * @author calyJa
 */
public class DataStoreTest {
    
    private static final String DATA_FOLDER = "data";
    
     public static void initialize() throws JDOMException, IOException, IllegalArgumentException, IllegalAccessException {
        /* 
        // tworzenie elementu "root"
        ComplexObject io = new ComplexObject();
        io.setName("root");
        List<Long> childOIDs = new ArrayList<Long>();
        */
        SBAStore sbaStore = Main.sbaStore;
        
        // wczytywanie pliku XML
        System.out.println("Loading xml file...");
        String str = DATA_FOLDER + File.separator + "test_data.xml";
        sbaStore.loadXML(str);
        System.out.println("File loaded...");
//        io.setChildOIDs(childOIDs);
        /*
        
        // tworzenie przykładowych obiektów i ich nasycanie
        System.out.println("Creating instances of sample classes Album, Artist and Track...");
        Artist artist = new Artist();
        Album album = new Album();
        Track track = new Track();
        System.out.println("Saturating objects...");
        artist.setfName("Justin");
        artist.setlName("Bieber");
        artist.setAge(15);
        album.setArtist(artist);
        album.setName("Worst album ever");
        album.setPrice(99.9);
        album.setRealeaseYear(2010);
        album.setReleased(true);
        
        // TODO problem z dwustronną referencją - nieskończona pętla
//        track.setAlbum(album);
        track.setName("Worst song ever");
        Track track2 = new Track();
//        track2.setAlbum(album);
        track2.setName("Worst song ever 2");
//        album.addTrack(track);
//        album.addTrack(track2);
        
        // dodanie obiektu do bazy
        System.out.println("Adding object Album...");
        childOIDs.add(sbaStore.addObject(album));
        io.setChildOIDs(childOIDs);
        */
        // wyświetlenie struktury z pliku oraz obiektu
        System.out.println("Printing structure...");
        System.out.println(sbaStore.printStructure());
        
    }    
    
}
